#pragma once

//#include <srs_utest_kernel.hpp>
#include <srs_utest.hpp>

#include <string>
#include <srs_kernel_file.hpp>
#include <srs_protocol_buffer.hpp>

class MockBufferReader: public ISrsBufferReader {
private:
    std::string str;
public:
    MockBufferReader(const char* data);
    virtual ~MockBufferReader();
public:
    virtual int read(void* buf, size_t size, ssize_t* nread);
};

class MockSrsFileWriter : public SrsFileWriter {
public:
    char* data;
    int offset;
public:
    MockSrsFileWriter();
    virtual ~MockSrsFileWriter();
public:
    virtual int open(const std::string& file);
    virtual void close();
public:
    virtual bool is_open();
    virtual int64_t tellg();
public:
    virtual int write(void* buf, size_t count, ssize_t* pnwrite);
    // for mock
public:
    void mock_reset_offset();
};

class MockSrsFileReader : public SrsFileReader {
public:
    char* data;
    int size;
    int offset;
public:
    MockSrsFileReader();
    virtual ~MockSrsFileReader();
public:
    virtual int open(const std::string& file);
    virtual void close();
public:
    virtual bool is_open();
    virtual int64_t tellg();
    virtual void skip(int64_t size);
    virtual int64_t lseek(int64_t offset);
    virtual int64_t filesize();
public:
    virtual int read(void* buf, size_t count, ssize_t* pnread);
    // for mock
public:
    // append data to current offset, modify the offset and size.
    void mock_append_data(const char* _data, int _size);
    void mock_reset_offset();
};
